#!/bin/sh

uci set luci.main.lang=auto
uci commit luci

uci set fstab.@global[0].anon_mount=1
uci commit fstab

rm -f /www/luci-static/resources/view/status/include/50_dsl.js
rm -f /www/luci-static/resources/view/status/include/70_ddns.js
rm -f /www/luci-static/resources/view/status/include/80_minidlna.js
rm -f /www/luci-static/resources/view/status/include/80_upnp.js

sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/aria2.lua
sed -i 's#admin/services#admin/nas#g' /usr/lib/lua/luci/view/aria2/settings_header.htm
sed -i 's/services/nas/g' /root/usr/share/luci/menu.d/luci-app-hd-idle.json
sed -i 's/services/nas/g' /root/usr/share/luci/menu.d/luci-app-minidlna.json
sed -i 's/services/nas/g' /root/usr/share/luci/menu.d/luci-app-mjpg-streamer.json
sed -i 's/services/nas/g' /root/usr/share/luci/menu.d/luci-app-p910nd.json
sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/usb_printer.lua
sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/xunlei.lua

ln -sf /sbin/ip /usr/bin/ip

sed -i "s/# //g" /etc/opkg/distfeeds.conf

sed -i 's/root::0:0:99999:7:::/root:$1$V4UetPzk$CYXluq4wUazHjmCDBCqXF.:0:0:99999:7:::/g' /etc/shadow
[ -f '/bin/bash' ] && sed -i 's|root:x:0:0:root:/root:/bin/ash|root:x:0:0:root:/root:/bin/bash|g' /etc/passwd

sed -i '/option disabled/d' /etc/config/wireless
sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh
wifi up

sed -i '/log-facility/d' /etc/dnsmasq.conf
echo "log-facility=/dev/null" >> /etc/dnsmasq.conf

rm -rf /tmp/luci-modulecache/
rm -f /tmp/luci-indexcache

mv /etc/openwrt_banner /etc/banner

exit 0
